<%@page import="biz.impl.UserBizImpl"%>
<%@page import="biz.UserBiz"%>
<%@page import="entity.User"%>
<%@page import="util.MD5Util"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%

	// 1.设置字符集
	request.setCharacterEncoding("utf-8");

	// 2.获取参数
	
	String username = request.getParameter("username");
	String password = request.getParameter("password");
	if(username==null || password==null||username.length()==0||password.length()==0){
		response.sendRedirect("login.jsp");
		return;
	}
	User user = new User();
	user.setPassword(password);
	user.setUsername(username);
	
	UserBiz biz = new UserBizImpl();
	try{
		User u = biz.login(user);
		session.setAttribute("LOGINUSER", u);
		response.sendRedirect("index.jsp");
	}catch(Exception e){
		request.setAttribute("msg", e.getMessage());
		request.getRequestDispatcher("login.jsp").forward(request, response);
	}
	
	
%>